home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
icon
/
packages.lha
/
packages
/
atari
/
ats.arc
/
TESTS.ARC
/
SIEVE.ICN
< prev
next >
Wrap
Text File
|
1990-03-28
|
563b
|
21 lines
#
# S I E V E O F E R A T O S T H E N E S
#
# This program illustrates the use of sets in implementing the
# classical sieve algorithm for computing prime numbers.
procedure main()
local limit, s, i
limit := 100
s := set()
every insert(s,1 to limit)
every member(s,i := 2 to limit) do
every delete(s,i + i to limit by i)
delete(s,1)
primes := sort(s)
write("There are ",*primes," primes in the first ",limit," integers.")
write("The primes are:")
every write(right(!primes,*limit + 1))
end